//
//  MBProgressHUD+WTJProgressHUD.m
//  Wutuojia
//
//  Created by anlun on 15/7/26.
//  Copyright (c) 2015年 Work. All rights reserved.
//

#import "MBProgressHUD+WTJProgressHUD.h"

@implementation MBProgressHUD (WTJProgressHUD)
+ (void)showHUDViewTo:(UIView *)view
                image:(UIImage *)image
                 text:(NSString *)text
         timeInterval:(NSTimeInterval)s{
    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
    hud.removeFromSuperViewOnHide = YES;
    hud.opacity = 0.5;
    hud.customView = [[UIImageView alloc] initWithImage:image];
    hud.labelText = text;
    hud.mode = MBProgressHUDModeCustomView;
    [view addSubview:hud];
    [hud show:YES];
    [hud hide:YES afterDelay:s];
}

#pragma mark detailText的改写
+(void)showDetailText:(NSString *)detailText icon:(NSString *)icon view:(UIView *)view duratino:(CGFloat)duration{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.detailsLabelText = detailText;
    hud.detailsLabelFont = [UIFont systemFontOfSize:14];
    hud.opacity = 0.5;
    // 设置图片
    hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
    // 再设置模式
    hud.mode = MBProgressHUDModeCustomView;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    
    // 1秒之后再消失
    [hud hide:YES afterDelay:duration];
}
@end
